home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1992 June: ROMin Holiday / ADC Developer CD (1992-06) (''ROMin Holiday'')_iso / Developer Connection - 06-1992.iso / Developer Essentials / DTS Sample Code / Snippets / Toolbox & IAC / ◊Other / ZoomWindow / DoWZoom.p < prev   
Encoding:
Text File  |  1990-02-01  |  2.6 KB  |  61 lines  |  [TEXT/MPS ]

  1. PROCEDURE DoWZoom(theWindow: WindowPtr; zoomDir: INTEGER);
  2. VAR
  3.   globalPortRect, theSect, zoomRect : Rect;
  4.   nthDevice, dominantGDevice : GDHandle;
  5.   sectArea, greatestArea : LONGINT;
  6.   bias : INTEGER;
  7.   sectFlag : BOOLEAN;
  8. BEGIN
  9.   { theEvent is a global EventRecord from the main event loop }
  10.   { savePort is a global GrafPtr for scratch                  }
  11.   IF TrackBox(theWindow,theEvent.where,zoomDir) THEN
  12.     BEGIN
  13.       GetPort(savePort);
  14.       SetPort(theWindow);
  15.       EraseRect(theWindow^.portRect);    {recommended for cosmetic reasons}
  16.       
  17.       { If there is the possibility of multiple gDevices, then we     }
  18.       { must check them to make sure we are zooming onto the right    }
  19.       { display device when zooming out.                              }
  20.       { sysConfig is a global SysEnvRec set up during initialization  }
  21.       IF (zoomDir = inZoomOut) AND sysConfig.hasColorQD THEN
  22.         BEGIN
  23.           { window's portRect must be converted to global coordinates }
  24.           globalPortRect := theWindow^.portRect;
  25.           LocalToGlobal(globalPortRect.topLeft);
  26.           LocalToGlobal(globalPortRect.botRight);
  27.           { must calculate height of window's title bar }
  28.           bias :=    globalPortRect.top - 1
  29.                   -  WindowPeek(theWindow)^.strucRgn^^.rgnBBox.top;
  30.           nthDevice := GetDeviceList;
  31.           greatestArea := 0;
  32.           { This loop checks the window against all the gdRects in the   }
  33.           { gDevice list and remembers which gdRect contains the largest }
  34.           { portion of the window being zoomed. }
  35.           WHILE nthDevice <> NIL DO
  36.             BEGIN
  37.               sectFlag := SectRect(globalPortRect,nthDevice^^.gdRect,theSect);
  38.               WITH theSect DO
  39.                 sectArea := LONGINT(right - left) * (bottom - top);
  40.               IF sectArea > greatestArea THEN
  41.                 BEGIN
  42.                   greatestArea := sectArea;
  43.                   dominantGDevice := nthDevice;
  44.                 END;
  45.               nthDevice := GetNextDevice(nthDevice);
  46.             END; {of WHILE}
  47.           { We must create a zoom rectangle manually in this case. }
  48.           { account for menu bar height as well, if on main device }
  49.           IF dominantGDevice = GetMainDevice THEN
  50.             bias := bias + GetMBarHeight;
  51.           WITH dominantGDevice^^.gdRect DO
  52.             SetRect(zoomRect,left+3,top+bias+3,right-3,bottom-3);
  53.           { Set up the WStateData record for this window. }
  54.           WStateDataHandle(WindowPeek(theWindow)^.dataHandle)^^.stdState := zoomRect;
  55.         END; {of Color QuickDraw conditional stuff}
  56.       
  57.       ZoomWindow(theWindow,zoomDir,TRUE);
  58.       SetPort(savePort);
  59.     END;
  60. END;
  61.